﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

namespace DigitalSolutionControls
{
    public class ModifiedDataGridView:DataGridView
    {
        private DataGridViewCellStyle headerCellStyle;

        public ModifiedDataGridView()
        {
            this.AllowUserToAddRows = false;
            this.AllowUserToDeleteRows = false;
            this.AllowUserToResizeRows = false;
            //this.ReadOnly = true;
            DataGridViewCellStyle alternatingStyle = new DataGridViewCellStyle();
            alternatingStyle.BackColor = Color.WhiteSmoke;
            this.AlternatingRowsDefaultCellStyle = alternatingStyle;
            this.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this.AutoGenerateColumns = false;
            this.BackgroundColor = Color.WhiteSmoke;
            this.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.RowHeadersVisible = false;
            this.RowTemplate.Height = 30;
            this.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            headerCellStyle = new DataGridViewCellStyle();
            headerCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            headerCellStyle.Font = new Font(this.Font.Name, 11.25F, FontStyle.Regular);
            headerCellStyle.WrapMode = DataGridViewTriState.True;
        }

        protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
        {
            base.OnColumnAdded(e);
            e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            this.ColumnHeadersDefaultCellStyle = headerCellStyle;
            base.OnPaint(e);
            //Debug.WriteLine("OnPaint");
        }
    }
}
